home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_DOC.ZIP / SPX_EFF.DOC < prev    next >
Text File  |  1993-09-15  |  6KB  |  180 lines

  1. { SPX Library Version 2.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.   SPX_EFF is the background effects unit.  It allows for special effect
  4. for backgrounds.  Such as parallax scrolling and background panning.
  5.   In effect the unit SPX_EFF is an enhanced version of a page copy routine.
  6. It does a 'warped' or modified copy from one page to another.
  7.  
  8. ───────────────────────────────────────────────────────────────────────────
  9. type
  10.   Pcycle       = ^Tcycle;
  11.   Tcycle       = object
  12.  
  13.   Tcycle is the main effects object.  There are many variables that effect
  14. the way one can display a background.
  15.  
  16. VARIABLES:
  17.      cyc_next:   The current value of the frequency counter.  By defalt its
  18.                  resolution changes every line drawn from 0..wmax-1;
  19.      from_x:     Left (X) position of the source page to copy;
  20.      from_y:     Top (Y) position of the source page to copy;
  21.      cyc_x:      Left (X) position of the destination page;
  22.      cyc_y:      Top (Y) position of the destination page;
  23.      cyc_width:  Width of the region to copy;
  24.      cyc_height: Height of the region to copy;
  25.      cycley:     Pan (Y) offset position. Value should be 0..cyc_height-1;
  26.      cyclex:     Pan (X) offset position. Value should be 0..cyc_width-1;
  27.      fr_size:    Calcuated frequency size. (Used for cosine copies);
  28.      am_size:    Amplitude size of cosine wave;
  29.      cycle_cos:  Cosine table
  30.  
  31.      ---------------------------------------------------
  32.      constructor Tcycle.init(freq,size:integer);
  33.  
  34.      Sets up the object.
  35.  
  36.       FREQ:   Frequency for cosine wave;
  37.       SIZE:   Cosine wave height (Amplitude)
  38.  
  39.      DEFAULTS:
  40.         CYCLEX       0
  41.         CYCLEY       0
  42.         CYC_WIDTH    320
  43.         CYC_HEIGHT   200
  44.  
  45.      ---------------------------------------------------
  46.      destructor Tcycle.done;virtual;
  47.  
  48.      Preforms and deallocation of the object;
  49.  
  50.      ---------------------------------------------------
  51.      procedure Tcycle.changewave(freq,size:integer);virtual;
  52.  
  53.      Changes the cosine table.
  54.  
  55.       FREQ:   Frequency for cosine wave;
  56.       SIZE:   Cosine wave height (Amplitude)
  57.  
  58.      ---------------------------------------------------
  59.      procedure Tcycle.docycle(from,too,mode:byte); virtual;
  60.  
  61.      Preforms an effect copy.
  62.  
  63.      FROM:  Source page to copy;
  64.      TOO:   Destination page;
  65.      MODE:  Type of copy
  66.  
  67.                  0  Regular copy
  68.                  1  Regular copy with panning
  69.                  2  Cosine wave copy
  70.                  3  User defined copy
  71.  
  72.      When setting the mode to 3, a call to usercycle is made for each
  73.      iteration of a horzontal line copied.  See procedure "usercycle" below.
  74.  
  75.      ---------------------------------------------------
  76.      procedure Tcycle.cycle_move; virtual;
  77.  
  78.      Pan procedure.  Updates the cyclex and cycley variables.
  79.  
  80.      OVERRIDE: often
  81.  
  82.      Use this procedure to update the panning coordintes.  The pan
  83.      coordinates are often linked to the player's user position to
  84.      create background motion.
  85.  
  86.      ---------------------------------------------------
  87.      procedure Tcycle.adjustcyclenext; virtual;
  88.  
  89.      Modifies the cyc_next variable.
  90.  
  91.      OVERRIDE: seldom.
  92.  
  93. ───────────────────────────────────────────────────────────────────────────
  94.  
  95. type
  96.   usercp = procedure (f,t,yline:longint);
  97.  
  98. var
  99.   usercycle : usercp; { user cycle procedure }
  100.   
  101.   When Tcycle.docycle is called with mode=3,  usercycle is called.  You must
  102.   define your own procedure and assign it to usercycle so that docycle will
  103.   call your procedure.
  104.  
  105.      procedure MyCycleLine(f,t,yline:longint);far;
  106.      begin
  107.      end;
  108.          .
  109.          .
  110.          .
  111.  
  112.      usercycle := MyCycleLine;
  113.  
  114.   Note that MyCycleLine must be declared as a far procedure and has the
  115.  same parameter list as usercp type.
  116.  
  117.    usercycle takes three arguments:
  118.  
  119.       F:     Pointer to the source page
  120.       T:     Pointer to the destination page
  121.       YLINE: Current row being displayed.
  122.  
  123.    To use F or T, typecast it as as a pointer. e.g.
  124.  
  125.      move(pointer(f)^,pointer(t)^,20); { copy 20 bytes }
  126.  
  127. ───────────────────────────────────────────────────────────────────────────
  128. procedure linemove(s,d:longint;cnt:word);
  129.  
  130.   Copies a segment of bytes from S to D.
  131.  
  132.       S:    Pointer to source;
  133.       D:    Pointer to destination;
  134.       CNT:  Number of byte to move
  135.  
  136. ───────────────────────────────────────────────────────────────────────────
  137. procedure wordmove(var source,dest;cnt:word);
  138.  
  139.   Copies a segment of bytes from S to D.
  140.  
  141.       S:    Pointer to source;
  142.       D:    Pointer to destination;
  143.       CNT:  Number of byte to move
  144.  
  145.   Uses word copies, use only if cnt is an even number.
  146.  
  147. ───────────────────────────────────────────────────────────────────────────
  148. procedure cycleline(f,t:longint;cyclex,cycle_width:word);
  149.  
  150.   Copies a segment of bytes from F to T.  wraping the bytes if needed.
  151.  
  152.       F:           Pointer to source;
  153.       T:           Pointer to destination;
  154.       cyclex:      Offset in destination;
  155.       cycle_width  Width of destination
  156.  
  157.    Example:
  158.  
  159.      F=source   T=Destination   cyclex=4   cycle_width=8
  160.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  161.     F  │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
  162.        └──┴──┴──┴──┴──┴──┴──┴──┘
  163.  
  164.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  165.     T  │ 5│ 6│ 7│ 8│ 1│ 2│ 3│ 4│
  166.        └──┴──┴──┴──┴──┴──┴──┴──┘
  167.  
  168.  
  169.      F=source   T=Destination   cyclex=0   cycle_width=8
  170.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  171.     F  │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
  172.        └──┴──┴──┴──┴──┴──┴──┴──┘
  173.  
  174.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  175.     T  │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
  176.        └──┴──┴──┴──┴──┴──┴──┴──┘
  177.  
  178. ───────────────────────────────────────────────────────────────────────────
  179.  
  180.